package edu.ccut.saturn.manager.dict.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IDataDictTypeInfo;
import edu.ccut.saturn.component.IParameterContext;

public class DictTypeListToMap extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		List<IDataDictTypeInfo> dictTypeList = (List<IDataDictTypeInfo>)parameterContext.getParameterValue(0);
		
		List<Map<String, String>> result = new ArrayList<Map<String,String>>();
		
		if(dictTypeList != null){
			
			for(IDataDictTypeInfo dictType : dictTypeList){
				
				Map<String, String> map = new HashMap<String, String>();
				
				map.put("key", dictType.getType());
				map.put("name",dictType.getName());
				
				result.add(map);
			}
		}
		
		parameterContext.setParameter(0, result);
	}
}